using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace ObjectMapper.Benchmark.DataModel
{
    internal class BillOfMaterialsConfiguration : EntityTypeConfiguration<BillOfMaterials>
    {
        public BillOfMaterialsConfiguration()
        {
            ToTable("Production.BillOfMaterials");
            HasKey(x => x.BillOfMaterialsId);

            Property(x => x.BillOfMaterialsId)
                .HasColumnName("BillOfMaterialsID")
                .IsRequired()
                .HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity);
            Property(x => x.ProductAssemblyId).HasColumnName("ProductAssemblyID").IsOptional();
            Property(x => x.ComponentId).HasColumnName("ComponentID").IsRequired();
            Property(x => x.StartDate).HasColumnName("StartDate").IsRequired();
            Property(x => x.EndDate).HasColumnName("EndDate").IsOptional();
            Property(x => x.UnitMeasureCode).HasColumnName("UnitMeasureCode").IsRequired().HasMaxLength(3);
            Property(x => x.BomLevel).HasColumnName("BOMLevel").IsRequired();
            Property(x => x.PerAssemblyQty).HasColumnName("PerAssemblyQty").IsRequired().HasPrecision(8, 2);
            Property(x => x.ModifiedDate).HasColumnName("ModifiedDate").IsRequired();
        }
    }
}